package www.bit.demo;

import java.sql.SQLOutput;

interface IUsb {
    void openDevice();
    void closeDevice();
}
class Mouse implements IUsb {

    @Override
    public void openDevice() {
        System.out.println("打开鼠标");
    }
    public void check() {
        System.out.println("点击鼠标");
    }

    @Override
    public void closeDevice() {
        System.out.println("关闭鼠标");
    }
}
class Keyboard implements IUsb {

    @Override
    public void openDevice() {
        System.out.println("打开键盘");
    }
    public void input() {
        System.out.println("输入键盘");
    }

    @Override
    public void closeDevice() {
        System.out.println("关闭键盘");
    }
}
class Computer {
    public void open() {
        System.out.println("打开电脑");
    }
    public void close() {
        System.out.println("关闭电脑");
    }
    public void useDevice(IUsb iUsb) {

        iUsb.openDevice();

        if (iUsb instanceof Mouse) {
            Mouse mouse = (Mouse)iUsb;
            mouse.check();

        } else if (iUsb instanceof Keyboard) {
            Keyboard keyboard = (Keyboard)iUsb;
            keyboard.input();

        }

        iUsb.closeDevice();
    }
}
public class Test {
    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.open();

        computer.useDevice(new Mouse());
       // computer.useDevice(new Keyboard());

        computer.close();


    }
}

/*class Rect12 implements IShape {
    public void draw() {
        System.out.println("画圆" );
    }
}
class Flower implements IShape {
    public void draw() {
        System.out.println("花花");
    }
}
 interface IShape {
     public int a = 10;

   public static final int bb = 2;
     int c = 3;

     void draw();

 }
 public class Test {
    public static void func(IShape iShape) {
        iShape.draw();
    }
     public static void main(String[] args) {
       *//* func(new Flower());
        func(new Rect12());*//*
         IShape iShape1 = new Rect12();
         IShape iShape2 = new Flower();
        IShape iShape[] = {iShape1,iShape2};
         for (int i = 0; i < iShape.length; i++) {
             func(iShape[i]);

         }

     }
}*/
   /* public static void func() {
        System.out.println("hh");
    }*/
